package com.itheima.service.Impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.PermissionDao;
import com.itheima.entity.PageResult;
import com.itheima.pojo.Permission;
import com.itheima.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionDao permissionDao;
//添加方法
    @Override
    public void add(Permission permission) {
        permissionDao.add(permission);
    }
//分页查询方法
    @Override
    public PageResult findPage(String queryString, Integer currentPage, Integer pageSize) {
//        使用分页助手
        PageHelper.startPage(currentPage,pageSize);
        String ss=queryString;
        if (ss!=null){
            ss="%"+queryString+"%";
        }
        Page<Permission> page= permissionDao.findPage(ss);
        return new PageResult(page.getTotal(),page.getResult());
    }
//权限编辑方法
    @Override
    public void edit(Permission permission) {
        permissionDao.edit(permission);
    }
//权限删除方法
    @Override
    public void delete(int id) {
        permissionDao.delete(id);
    }
}
